// pages/tools/jifenruhu/index/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        show1: false,
        show2: false,
        showResult: false,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {

    },

    formSubmit(e) {
        let resData = e.detail.value;
        if (resData.propertyHouse != '' && resData.rentalHouse == '') {
            let result = Number(resData.propertyHouse) + (Number(resData.endowment) * 1.5) - (Number(resData.credit) * Number(resData.creditInput ? resData.creditInput : 0)) - (Number(resData.creditfull) * Number(resData.creditfullInput ? resData.creditfullInput : 0)) - Number(resData.dishonesty) - Number(resData.crime) - Number(resData.punish)
            this.setData({
                result: result.toFixed(1),
                showResult: true,
            })
        } else if (resData.propertyHouse == '' && resData.rentalHouse != '') {
            let result = (Number(resData.rentalHouse) * 0.2) + (Number(resData.endowment) * 1.5) - (Number(resData.credit) * Number(resData.creditInput ? resData.creditInput : 0)) - (Number(resData.creditfull) * Number(resData.creditfullInput ? resData.creditfullInput : 0)) - Number(resData.dishonesty) - Number(resData.crime) - Number(resData.punish)
            this.setData({
                result: result.toFixed(1),
                showResult: true,
            })
        } else if (resData.propertyHouse != '' && resData.rentalHouse != '') {
            ks.showModal({
                title: '温馨提示',
                content: '稳定居住选项只能二选一哦~',
                showCancel: false,
                confirmText: "重新填写"
            })
        }
    },

    radioChange(e) {
        let flag = e.currentTarget.dataset.flag;
        let value = e.detail.value;
        if (flag == 1) {
            if (value == "15") {
                this.setData({
                    show1: true,
                })
            } else {
                this.setData({
                    show1: false,
                })
            }
        } else {
            if (value == "30") {
                this.setData({
                    show2: true,
                })
            } else {
                this.setData({
                    show2: false,
                })
            }
        }
    },

    previewBtn() {
        ks.previewImage({
            current: '/images/szbdb.png', // 当前显示图片的http链接
            urls: ['/images/szbdb.png'], // 需要预览的图片http链接列表
        })
    },

    certainBtn() {
        this.setData({
            showResult: false,
        })
    },
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {
        return {
            title: "深圳纯积分入户分值估算",
            imageUrl: "http://imgbdb3.bendibao.com/xcxbdb/file/20212/9/20210209161843_68677.jpg"
        }
    },

    // 分享朋友圈
    onShareTimeline: function() {
        return {
            title: "深圳纯积分入户分值估算",
            imageUrl: "http://imgbdb3.bendibao.com/xcxbdb/file/20212/9/20210209161843_68677.jpg"
        }
    },
})